using System.Collections.Generic;

namespace WIT.DAQ.Core.Helper;

public class DataTypeHelper
{
	public static bool[] IntToBitArray(int value, int? length = null)
	{
		List<bool> list = new List<bool>();
		do
		{
			list.Add(value % 2 == 1);
			value /= 2;
		}
		while (value >= 1);
		list.Reverse();
		if (length.HasValue && list.Count < length)
		{
			int? num = length - list.Count;
			while (num-- > 0)
			{
				list.Insert(0, item: false);
			}
		}
		return list.ToArray();
	}
}
